package com.huawei.appgallery.wishservice.ui.activity;

import android.app.ActionBar;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.activity.BaseActivity;
import com.huawei.appgallery.wishwall.api.IWishWallFragmentProtocol;
import com.huawei.hmf.annotation.ActivityDefine;
import com.huawei.updatesdk.service.otaupdate.UpdateStatusCode.DialogButton;
import huawei.widget.HwSubTabWidget;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import o.azb;
import o.AccountBussinessListener;
import o.ccp;
import o.cgv;
import o.cip;
import o.dbx;
import o.dbz;
import o.dcb;
import o.dcc;
import o.ddm;
import o.ddo;
import o.dgp;
import o.doo;
import o.ContentManager;
import o.eod;
import o.eoj;
import o.CollectCheck;
import o.eqn;
import o.eqq;
import o.evx;
import o.fho;
import o.fiu;
import o.fjb;
import o.FragmentTransaction;

@ActivityDefine(alias = "wish_activity")
public class WishActivity extends BaseActivity implements dcc {
    private ViewPager ˊॱ;
    private HwSubTabWidget ˋॱ;
    private RelativeLayout ˏॱ;
    private cip ͺ;
    private ddm ॱˊ;

    static class a implements AccountBussinessListener {
        private SoftReference<WishActivity> ˊ;

        public a(WishActivity wishActivity) {
            this.ˊ = new SoftReference(wishActivity);
        }

        public void onAccountBusinessResult(ccp o_ccp) {
            WishActivity wishActivity = (WishActivity) this.ˊ.get();
            if (!(wishActivity == null || wishActivity.isFinishing() || DialogButton.CONFIRM != o_ccp.ˎ)) {
                eqq.ˋ().ˊ("WishEventListener");
                wishActivity.finish();
            }
            eoj.ˋ().ˊ("WishEventListener");
        }
    }

    static class b implements eqn {
        private SoftReference<WishActivity> ˏ;

        public b(WishActivity wishActivity) {
            this.ˏ = new SoftReference(wishActivity);
        }

        public void onResult(int i) {
            WishActivity wishActivity = (WishActivity) this.ˏ.get();
            if (wishActivity == null || wishActivity.isFinishing()) {
                if (202 == i) {
                    WishActivity.ˊˋ();
                }
            } else if (202 == i) {
                wishActivity.ͺ();
            } else {
                wishActivity.finish();
            }
            eqq.ˋ().ˊ("WishEventListener");
        }
    }

    static class c implements huawei.widget.HwSubTabWidget.b {
        private WeakReference<WishActivity> ˋ;

        public c(WishActivity wishActivity) {
            this.ˋ = new WeakReference(wishActivity);
        }

        public void ˊ(huawei.widget.HwSubTabWidget.a aVar, FragmentTransaction kaVar) {
        }

        public void ˎ(huawei.widget.HwSubTabWidget.a aVar, FragmentTransaction kaVar) {
            if (this.ˋ != null) {
                WishActivity wishActivity = (WishActivity) this.ˋ.get();
                if (wishActivity != null) {
                    ViewPager ˎ = wishActivity.ˊॱ;
                    if (ˎ != null) {
                        ˎ.setCurrentItem(aVar.ˏ());
                    }
                }
            }
        }

        public void ॱ(huawei.widget.HwSubTabWidget.a aVar, FragmentTransaction kaVar) {
        }
    }

    static class d implements dbz {
        private WeakReference<WishActivity> ˋ;

        public d(WishActivity wishActivity) {
            this.ˋ = new WeakReference(wishActivity);
        }

        public void ˊ(Fragment fragment, boolean z) {
            if (this.ˋ != null) {
                WishActivity wishActivity = (WishActivity) this.ˋ.get();
                if (wishActivity != null) {
                    ddm ॱ = wishActivity.ॱˊ;
                    RelativeLayout ˏ = wishActivity.ˏॱ;
                    if (ॱ != null && ˏ != null) {
                        Fragment ॱ2 = ॱ.ॱ();
                        if (fragment != null && fragment == ॱ2) {
                            ˏ.setVisibility(z ? 0 : 8);
                        }
                    }
                }
            }
        }
    }

    static class e implements ViewPager.OnPageChangeListener {
        private WeakReference<WishActivity> ˏ;

        public e(WishActivity wishActivity) {
            this.ˏ = new WeakReference(wishActivity);
        }

        public void onPageScrolled(int i, float f, int i2) {
            if (this.ˏ != null) {
                WishActivity wishActivity = (WishActivity) this.ˏ.get();
                if (wishActivity != null) {
                    HwSubTabWidget ˊ = wishActivity.ˋॱ;
                    if (ˊ != null) {
                        ˊ.setSubTabScrollingOffsets(i, f);
                    }
                }
            }
        }

        public void onPageScrollStateChanged(int i) {
            if (this.ˏ != null) {
                WishActivity wishActivity = (WishActivity) this.ˏ.get();
                if (wishActivity != null) {
                    HwSubTabWidget ˊ = wishActivity.ˋॱ;
                    if (ˊ != null) {
                        ˊ.setSubTabSelected(i);
                    }
                }
            }
        }

        public void onPageScrolled(int i) {
        }
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        cgv.ˋ(this, o.ddi.d.ˏ, o.ddi.d.ˊ);
        setContentView(o.ddi.a.ˏ);
        ʼॱ();
        ˉ();
        ˋˊ();
    }

    private void ͺ() {
        this.ˋॱ = (HwSubTabWidget) findViewById(o.ddi.e.ˎ);
        boolean ॱ = dbx.ˏ().ॱ();
        List ˏ = ˏ(ॱ);
        if (ॱ) {
            this.ˋॱ.setVisibility(0);
            ˊ(ˏ);
        }
        this.ˊॱ = (ViewPager) findViewById(o.ddi.e.ˋ);
        this.ˊॱ.addOnPageChangeListener(new e(this));
        this.ॱˊ = new ddm(this, ˏॱ(), ˏ);
        this.ॱˊ.ˊ(new d(this));
        this.ˊॱ.setAdapter(this.ॱˊ);
    }

    private void ˊ(List<ddo> list) {
        if (this.ˋॱ != null && !CollectCheck.isEmpty((List) list)) {
            this.ˋॱ.ˎ();
            int size = list.size();
            for (int i = 0; i < size; i++) {
                boolean z;
                ddo o_ddo = (ddo) list.get(i);
                HwSubTabWidget hwSubTabWidget = this.ˋॱ;
                hwSubTabWidget.getClass();
                huawei.widget.HwSubTabWidget.a aVar = new huawei.widget.HwSubTabWidget.a(hwSubTabWidget, o_ddo.ॱ(), new c(this));
                aVar.ˎ(i);
                hwSubTabWidget = this.ˋॱ;
                if (i == 0) {
                    z = true;
                } else {
                    z = false;
                }
                hwSubTabWidget.ॱ(aVar, z);
            }
        }
    }

    private List<ddo> ˏ(boolean z) {
        List<ddo> arrayList = new ArrayList();
        ddo o_ddo = new ddo();
        o_ddo.ˋ(ॱˊ());
        o_ddo.ˏ(getString(o.ddi.b.ˋ));
        arrayList.add(o_ddo);
        if (z) {
            o_ddo = new ddo();
            o_ddo.ˋ(ᐝॱ());
            o_ddo.ˏ(getString(o.ddi.b.ʽ));
            arrayList.add(o_ddo);
        }
        return arrayList;
    }

    private fjb ॱˊ() {
        return fho.ˏ().ˋ("WishList").ˎ("wishlist.fragment");
    }

    private fjb ᐝॱ() {
        int i = 0;
        String[] strArr = new String[]{getString(o.ddi.b.ॱ), getString(o.ddi.b.ˊ), getString(o.ddi.b.ʻ)};
        String[] strArr2 = new String[]{"allwishwall", "mypublistwishwall", "myreplywishwall"};
        List arrayList = new ArrayList();
        while (i < strArr.length) {
            String str = strArr[i];
            String str2 = strArr2[i];
            dgp o_dgp = new dgp();
            o_dgp.ˎ(str);
            o_dgp.ˋ(str2);
            arrayList.add(o_dgp);
            i++;
        }
        fjb ˎ = fho.ˏ().ˋ("WishWall").ˎ("wishwall.fragment");
        if (ˎ != null) {
            ((IWishWallFragmentProtocol) ˎ.ˊ()).setColumnNavigatorList(arrayList);
        }
        return ˎ;
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (this.ॱˊ != null) {
            Fragment ॱ = this.ॱˊ.ॱ();
            if (ॱ != null) {
                ॱ.ॱ(i, i2, intent);
            }
        }
    }

    private void ʼॱ() {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        View findViewById = findViewById(o.ddi.e.ॱ);
        azb.ˏ(findViewById);
        ((TextView) findViewById.findViewById(o.ddi.e.ᐝ)).setText(o.ddi.b.ˎ);
        this.ˏॱ = (RelativeLayout) findViewById.findViewById(o.ddi.e.ʻ);
        this.ˏॱ.setVisibility(8);
        this.ˏॱ.setOnClickListener(new evx(this) {
            final /* synthetic */ WishActivity ˊ;

            {
                this.ˊ = r1;
            }

            public void ˋ(View view) {
                this.ˊ.ॱ(view);
            }
        });
        findViewById.findViewById(o.ddi.e.ˊ).setOnClickListener(new evx(this) {
            final /* synthetic */ WishActivity ॱ;

            {
                this.ॱ = r1;
            }

            public void ˋ(View view) {
                this.ॱ.onBackPressed();
            }
        });
    }

    private void ॱ(View view) {
        if (this.ॱˊ != null && (this.ॱˊ.ॱ() instanceof dcb)) {
            ((dcb) this.ॱˊ.ॱ()).ʾॱ();
        }
        final PopupMenu popupMenu = new PopupMenu(this, view);
        getMenuInflater().inflate(o.ddi.c.ॱ, popupMenu.getMenu());
        popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener(this) {
            final /* synthetic */ WishActivity ˎ;

            public boolean onMenuItemClick(MenuItem menuItem) {
                if (menuItem.getItemId() == o.ddi.e.ˏ && this.ˎ.ॱˊ != null && (this.ˎ.ॱˊ.ॱ() instanceof dcb)) {
                    ((dcb) this.ˎ.ॱˊ.ॱ()).ʼᐝ();
                }
                popupMenu.dismiss();
                return false;
            }
        });
        popupMenu.show();
    }

    public void d_(String str) {
        TextView textView = (TextView) findViewById(o.ddi.e.ॱ).findViewById(o.ddi.e.ᐝ);
        if (TextUtils.isEmpty(str)) {
            textView.setText(o.ddi.b.ˎ);
        } else {
            textView.setText(str);
        }
        textView.requestLayout();
    }

    private static void ˊˋ() {
        fiu.ˊ().ˏ(ContentManager.getInstant().getContext(), fho.ˏ().ˋ("WishService").ˎ("wish_activity"));
    }

    private void ˉ() {
        if (this.ͺ == null) {
            this.ͺ = new cip();
            this.ͺ.ˎ(findViewById(o.ddi.e.ʼ));
            this.ͺ.ˋ(new OnClickListener(this) {
                final /* synthetic */ WishActivity ˊ;

                {
                    this.ˊ = r1;
                }

                public void onClick(View view) {
                    this.ˊ.ˋˊ();
                }
            });
        }
        this.ͺ.ॱ(0);
    }

    private void ˊˊ() {
        if (this.ͺ != null) {
            this.ͺ.ॱ(8);
            this.ͺ = null;
        }
    }

    private void ˋˊ() {
        if (doo.ˊ((Context) this)) {
            ˊˊ();
            if (UserSession.getInstance().isLoginSuccessful()) {
                ͺ();
                return;
            }
            eoj.ˋ().ˎ("WishEventListener", new a(this));
            eqq.ˋ().ˎ("WishEventListener", new b(this));
            eod.ॱ((Context) this);
            finish();
            return;
        }
        this.ͺ.ॱ(getString(o.ddi.b.ˏ), true);
    }
}
